package org.imdm.portal.loadchecker.telnet;

import org.imdm.portal.loadchecker.ui.LoadInfo;

public class ReadUserCommand extends Command {

	public ReadUserCommand(TelnetClientAdvance telnet) {
		super(telnet);
	}

	public String execute() throws TelnetException {
		String userInfo = LoadInfo._UNKNOWN;
		String cd = sendCommand("cd /opt/MagellanNMS");
		if ( cd.indexOf("No such file or directory") >= 0 )
			return userInfo;
		String info = sendCommand("ls -al | grep system");

		if (info != null) {
			String[] infos = info.split("\\s+");
			if (infos != null && infos.length > 3) {
				userInfo = infos[2];
			}
		}

		return userInfo;
	}

}
